﻿<phone:PhoneApplicationPage
    x:Class="QuickWeb.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:QuickWeb;assembly=QuickWeb"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    mc:Ignorable="d"
    d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True"
    shell:SystemTray.Opacity="0.0"
>


    <phone:PhoneApplicationPage.Resources>



        <DataTemplate x:Name="MyHeaderTemplate">
            <TextBlock Text="{Binding}" 
                       Foreground="{StaticResource PhoneAccentBrush}"  
                       TextWrapping="Wrap" />
        </DataTemplate>

        <DataTemplate x:Key="MyTitleTemplate">
            <TextBlock 
                Text="{Binding}"                
                />
        </DataTemplate>

        <DataTemplate x:Key="FeedSourceTemplate"  >  
                <Grid  >
                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu>
                        <toolkit:MenuItem  Header="{Binding Path=LocalizedResources.delete, Source={StaticResource LocalizedStrings}}" Click="RemoveFeed"/>
                        </toolkit:ContextMenu>
                    </toolkit:ContextMenuService.ContextMenu>
                    <Grid.RowDefinitions>
                        <RowDefinition  />
                        <RowDefinition  />                        
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>                    
                        <TextBlock 
                            Grid.Row="0"
                            Grid.Column="0"
                            Text="{Binding Title}"                            
                            Style="{StaticResource PhoneTextTitle2Style}"  
                            TextWrapping="Wrap"
                        />
                        <TextBlock 
                            Grid.Row="1"
                            Grid.Column="0"
                            Text="{Binding Description}"                      
                            Style="{StaticResource PhoneTextSubtleStyle}"
                            TextWrapping="Wrap"
                        />
                </Grid>
            
        </DataTemplate>

        <DataTemplate x:Key="ClipTemplate"  >
            <Grid  >
                <toolkit:ContextMenuService.ContextMenu>
                    <toolkit:ContextMenu>
                        <toolkit:MenuItem  
                            Header="{Binding Path=LocalizedResources.delete, Source={StaticResource LocalizedStrings}}" 
                            Click="RemoveClip"
                        />
                    </toolkit:ContextMenu>
                </toolkit:ContextMenuService.ContextMenu>
                <Grid.RowDefinitions>
                    <RowDefinition  />
                    <RowDefinition  />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <TextBlock 
                            Grid.Row="0"
                            Grid.Column="0"
                            Text="{Binding Title}"                            
                            Style="{StaticResource PhoneTextTitle2Style}"  
                            TextWrapping="Wrap"
                        />
                <TextBlock 
                            Grid.Row="1"
                            Grid.Column="0"
                            Text="{Binding Description}"                      
                            Style="{StaticResource PhoneTextSubtleStyle}"
                            TextWrapping="Wrap"
                        />
            </Grid>

        </DataTemplate>

        <!--<local:FeedSources x:Name="listEjemploDeFeeds">
            <local:FeedData Title="Todos" Description="Noticias mas recientes"/>
            <local:FeedData Title="Gizmodo" Description="The Gadget Guide"/>
            <local:FeedData Title="Engadget RSS Feed" Description="Engadget"/>
        </local:FeedSources>-->

       

    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot"  >
        <!--Background="Transparent"-->

        <!--<Grid.Background>
            <ImageBrush 
                ImageSource="/Assets/BooksBackground.jpg" 
                Stretch="UniformToFill"
                Opacity="0.6"
            />
        </Grid.Background>-->



        <!--Pivot Control-->
        <phone:Pivot 
            
            x:Name="pivot"
            Title="{Binding Path=LocalizedResources.appTitle, Source={StaticResource LocalizedStrings}}" 
            SelectionChanged="Pivot_SelectionChanged"             
            TitleTemplate="{StaticResource MyTitleTemplate}" 
            Loaded="Pivot_Loaded"
            
        >

            <!--Quick search item-->
            <phone:PivotItem x:Name="searchPivot"  >
                <phone:PivotItem.Header >
                    <TextBlock 
                        Text="{Binding Path=LocalizedResources.quickSearch, Source={StaticResource LocalizedStrings}}"                                                
                                            
                    />
                </phone:PivotItem.Header>

                <!--Double line list with text wrapping-->
                <Grid x:Name="browserGrid">

                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>


                    <TextBox 
                        x:Name="searchBox" 
                        Grid.Row="1" 
                        TextWrapping="Wrap" 
                        Text="{Binding Path=LocalizedResources.SearchBing, Source={StaticResource LocalizedStrings}}" 
                        GotFocus="searchBox_GotFocus"
                        LostFocus="searchBox_LostFocus"
                        Foreground="Gray" InputScope="Search"                         
                        KeyDown="searchBox_KeyDown"
                    />
                    <!--<Button Grid.Row="2" HorizontalAlignment="Right">
                        <Grid>
                            <Grid.Background>
                                <ImageBrush ImageSource="/Assets/overflowdots_light.png"/>
                            </Grid.Background>
                        </Grid>
                    </Button>-->

                </Grid>

            </phone:PivotItem>

            <!--Feeds View-->
            <phone:PivotItem x:Name="readPivot" >
                <phone:PivotItem.Header>
                    <TextBlock 
                        Text="{Binding Path=LocalizedResources.reader, Source={StaticResource LocalizedStrings}}" 
                        TextWrapping="Wrap"
                        
                    />
                </phone:PivotItem.Header>
                <!--Agregar el contenido aqui-->
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <!--<RowDefinition Height="Auto" />-->
                        <!--<RowDefinition Height="Auto" />-->
                    </Grid.RowDefinitions>
                    
                    <Grid >
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <!--<RowDefinition Height="Auto" />-->
                        </Grid.RowDefinitions>
                        <!--<TextBlock Text="sources" Style="{StaticResource PhoneTextTitle2Style}"/>-->
                        <ListBox 
                            ScrollViewer.VerticalScrollBarVisibility="Auto"
                            ItemTemplate="{StaticResource FeedSourceTemplate}" 
                            x:Name="feedsSourceList"                             
                            Tap="feedsSourceList_Tap"
                            HorizontalAlignment="Stretch"
                            HorizontalContentAlignment="Stretch"
                        />
                    </Grid>
                    <TextBlock                         
                        x:Name="noItemsTipText" 
                        Visibility="Collapsed"
                        TextWrapping="Wrap"
                        Style="{StaticResource PhoneTextGroupHeaderStyle}" 
                    >
                    </TextBlock>
                    <!--<ListBox Grid.Row="1" >
                        
                    </ListBox>-->
                </Grid>
                

            </phone:PivotItem>

            <!--Pivot con los clips almacenados -->
            <phone:PivotItem x:Name="clipsPivot" >
                <phone:PivotItem.Header>
                    <TextBlock 
                        Text="{Binding Path=LocalizedResources.feedsClipped, Source={StaticResource LocalizedStrings}}" 
                        TextWrapping="Wrap"                        
                    />                    
                </phone:PivotItem.Header>
                <Grid>
                    <ListBox 
                        ScrollViewer.VerticalScrollBarVisibility="Auto"
                        ItemTemplate="{StaticResource ClipTemplate}" 
                        x:Name="clipsList"                     
                        Tap="clipsStoredList_Tap"
                        HorizontalAlignment="Stretch"
                        HorizontalContentAlignment="Stretch"
                    />
                    <TextBlock 
                        
                        x:Name="noClipsTipText" 
                        Visibility="Collapsed"
                        TextWrapping="Wrap"
                        Style="{StaticResource PhoneTextGroupHeaderStyle}" 
                    >
                    </TextBlock>

                </Grid>
                
            </phone:PivotItem>
                

        </phone:Pivot>

        <!--Uncomment to see an alignment grid to help ensure your controls are
            aligned on common boundaries.  The image has a top margin of -32px to
            account for the System Tray. Set this to 0 (or remove the margin altogether)
            if the System Tray is hidden.

            Before shipping remove this XAML and the image itself.-->
        <!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" IsHitTestVisible="False" />-->
    </Grid>

</phone:PhoneApplicationPage>